package model

import (
	sqlc "bgs/db/sqlc"
	"bgs/util"
)

var (
	activitiesNeedTypeInfo = []string{
		string(sqlc.EmActivityTypeCheckIn1),
		string(sqlc.EmActivityTypeLottery1),
	}

	activitiesStatActivityCountOfUserInvolvedByUserProcedure = []string{
		string(sqlc.EmActivityTypeCheckIn1),
		string(sqlc.EmActivityTypeLottery1),
	}
)

// CheckNeedTypeInfo 活动类型是否需要扩展活动信息
func CheckNeedTypeInfo(activityType string) bool {
	return util.StringContains(activitiesNeedTypeInfo, activityType)
}

// CheckInvolvedUseUserProcedure 用户参与的活动数是否按照活动用户过程来统计
func CheckActivityCountOfUserInvolvedByUserProcedure(activityType string) bool {
	return util.StringContains(activitiesStatActivityCountOfUserInvolvedByUserProcedure, activityType)
}

type ActivityTypeAsFeatureCheckAvailable struct {
	ActivityType string
	IsAvailable  bool
}

// CheckIn1Info 签到1的类型信息
type CheckIn1Info struct {
	AwardOnceCoins     BCoin  `json:"award_once_coins,omitempty"`      // 单次奖励星币数
	AwardReachMaxCoins BCoin  `json:"award_reach_max_coins,omitempty"` // 达到最大连签次数奖励的星币数
	MaxContinuous      uint32 `json:"continuous_max"`                  // 最大连签次数
}

type PrizeDistribution struct {
	Prize     uint32   `json:"prize"`     // 几等奖
	Available bool     `json:"available"` // 奖品的抽奖资格是否有效
	Wins      []uint32 `json:"wins"`      // (0-1000]
}

// Lottery1Info 抽奖1的类型信息
type Lottery1Info struct {
	UIType        string              `json:"ui_type"`       // 前端消费格式,透传
	WinRate       uint32              `json:"win_rate"`      // 活动中奖率 (难10、中50、易90、自定义100)辅助实现,
	PrizeRates    []uint32            `json:"prize_rates"`   // 奖项真实中奖率(目前前端传入) 抽奖类奖项必须[4,7](分子)
	Cardinality   uint32              `json:"cardinality"`   // 100/1000/10000(分母)
	Distributions []PrizeDistribution `json:"distributions"` // 奖项分布 [{1,[15,213,511]}, {2, {23,123,182,321,512,982}}]
}

// ActivityTypeInfo (check_in__1 and lottery__1)
type ActivityTypeInfo struct {
	CheckIn1Ptr *CheckIn1Info `json:"check_in__1,omitempty"`
	Lottery1Ptr *Lottery1Info `json:"lottery__1,omitempty"`
}
